package com.experian.daas.baseinfo.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.experian.daas.baseinfo.dao.UserDao;
import com.experian.daas.baseinfo.entity.User;
import com.experian.daas.baseinfo.service.UserService;
import com.github.pagehelper.PageHelper;

@Service
public class UserServiceImpl implements UserService{
	@Resource
	private UserDao userDao;
	
	
	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void addUser(User user){
		userDao.insert(user);
	}
	
	@Override
	public List<User> getUsers(){
		List<User> users = userDao.selectAll();
		return users;
	}
	
	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(User user){
		userDao.updateByPrimaryKey(user);
	}
	
	@Override
	public List<User> page(int curPage,int pageSize){
		PageHelper.startPage(curPage, pageSize);
		return userDao.selectAll();
	}
}
